package com.example.scaffold_demo.mvp.di.user.presenter;

import com.example.httplibrary.mvp.BasePresenter;
import com.example.scaffold_demo.BaseApplication;
import com.example.scaffold_demo.http.ApiService;
import com.example.scaffold_demo.http.ProgressSubcriber;
import com.example.scaffold_demo.http.ServiceGenerator;
import com.example.scaffold_demo.http.reponse.RxHttpReponseCompat;
import com.example.scaffold_demo.mvp.di.user.bean.UserInfoDateBean;
import com.example.scaffold_demo.mvp.di.user.contract.UserLoginContract;

/**
 * Author: 李巷阳
 * Date: 2020/6/16
 * Part:
 * Description:
 */
public class UserLoginPresenter extends BasePresenter<UserLoginContract.View> implements UserLoginContract.Presenter {


    @Override
    public void toLogin(String black_box, String phone, String passwd) {
        ServiceGenerator.getApiService(ApiService.class).login(black_box, phone, passwd).compose(RxHttpReponseCompat.<UserInfoDateBean>compatResult())
                .subscribe(new ProgressSubcriber<UserInfoDateBean>(BaseApplication.getContext(), getView()) {
                    @Override
                    public void onNext(UserInfoDateBean loginBean) {
                        getView().toLoginSuccess(loginBean);
                    }
                });
        ;
    }
}
